package com.abel.cas;

/**
 * @author xiachao
 * @date 2019/2/17
 */
public class CasCounter {
    private SimulatedCAS value;

    public int getValue(){
        return value.get();
    }

    public int increment(){
        int v;
        do{
            v = getValue();
        }while(!value.compareAndSet(v, v+1));
        return getValue();
    }
}
